﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Loadimg</title>
    @Scripts.Render("~/UEditor/Config")
    @Scripts.Render("~/bundles/modernizr")
</head>
<body>
    <textarea id="uploadEditor" style="display: none;"></textarea>
    <div> 
        @using (Html.BeginForm())
        {
            @Html.AntiForgeryToken()
            <div id="box"></div>
            <button type="button" id="j_upload_img_btn" class="btn btn-primary">上传图片</button>

            <button type="submit" value="Submit">Submit</button>
        }
    </div>

        <script>
            //上传图片标题的UE编辑器，只有上传图片功能 ，注意：并不是很完善
            var uploadEditor = UE.getEditor("uploadEditor", {
                isShow: false,
                focus: false,
                enableAutoSave: false,
                autoSyncData: false,
                autoFloatEnabled: false,
                wordCount: false,
                sourceEditor: null,
                scaleEnabled: true,
                toolbars: [["insertimage"]]
            });
            //绑定上图片按钮的单击事件，单击事件弹出上传图片标题的UE编辑器
            document.getElementById('j_upload_img_btn').onclick = function () {
                var dialog = uploadEditor.getDialog("insertimage");
                dialog.title = '上传图片';
                dialog.render();
                dialog.open();
            };

            // 监听多图上传和上传附件组件的插入动作
            uploadEditor.ready(function () {
                uploadEditor.addListener("beforeInsertImage", _beforeInsertImage);
            });

            // 多图上传动作
            function _beforeInsertImage(t, result) {
                var imageHtml = "";
                var box = document.getElementById('box');
                for (var i in result) {
                    imageHtml += '<input type=text id=picsrc name=picsrc value=' + result[i].src + '/><br />';
                }
                box.innerHTML = imageHtml;
            }

        </script>

</body>
</html>
